import React from "react";
import { connect } from "react-redux";


const mapStateToProps = state => {
  // state.auth  命名空间中 是以combineReducers  传入的对象的键值为区分的
  return {
    count: state.counter.count,
  }
}

const mapDispatchToProps = dispatch => {
  return {
    addCount: action => dispatch(action),
  }
}

@connect(mapStateToProps, mapDispatchToProps)
class Counter extends React.Component{
    constructor(props) {
        super(props)
        console.log(props);
    }
    render() {
        const { addCount, count } = this.props;
        return <div>
            { count }
            <button onClick={() => addCount({type: 'addition'})}>按钮</button>
        </div>
    }
}

export default Counter;


 